package com.njwb.day15.zqzb.Age;

public class People {
    private int age;

    public int getAge() {
        return age;
    }

    // 年龄设置方法，带异常处理
    public void setAge(int age) throws AgeOutOfRangeException {
        if (age < 0 || age > 120) {
            throw new AgeOutOfRangeException("年龄必须在0到120之间！");
        }
        this.age = age;
    }
}
